package com.wit.zhenghao.day10;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

public class DemoFile {

	@Test
	public void test() throws IOException {
		File file = new File("D:\\test.txt");
		
		boolean isCreated =  file.createNewFile();
		System.out.println(isCreated);
	}
	
	@Test
	public void testDirectory() throws IOException {
		File dir = new File("D:\\test");
		boolean isCreated = dir.mkdirs();
		System.out.println(isCreated);
		
		File dir2 = new File("D:\\test\\java\\day10");
		dir2.mkdirs();
		if(dir2.exists()) {
			System.out.println("文件夹存在！！");
		}
		
		File file = new File("test.java");
		file.createNewFile();
		System.out.println(file.getAbsolutePath());
	}
	
	@Test
	public void testDir() throws IOException {
		File dir = new File("data/day01");
		dir.mkdirs();
		
		File f = new File(dir,"test1.txt");
		f.createNewFile();
		System.out.println(dir.getAbsolutePath());
	}
	
	@Test
	public void testDelete() {
		File dir = new File("data/day01");
		dir.mkdirs();
		
		File f = new File(dir,"test1.txt");
		f.delete();
		dir.delete();
		dir.getParentFile().delete();
	}
}
